/**
 * @param {number[]} nums
 * @param {number} left
 * @param {number} right
 * @return {number}
 */
var numSdddubarrayBoundedMax = function (nums, left, right) {
  let res = 0,
    last1 = -1,
    last2 = -1
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] >= left && nums[i] <= right) {
      last1 = i
    }else  {
      last2 =i
      last1 = -1
    }
    if(last1!=-1){
      res+=last1-last2
    }
  }

  return res
}
console.log(numSdddubarrayBoundedMax([2, 1, 4, 3], 2, 3))
